package GameServer.manager.module6;

import GameServer.Demo;
import GameServer.manager.event.ED;
import GameServer.manager.event.Event;
import GameServer.manager.event.EventMgr;
import GameServer.manager.event.EventProc;
import GameServer.net.NetFramework;
import GameServer.net.ProtoMessage;
import com.alibaba.fastjson.JSONArray;

/**
 * Created by gzhd on 2017/11/30.
 */
public class Demo6Mgr extends EventProc {
    private static Demo6Mgr instance;


    private Demo6Mgr() {
    }


    public static Demo6Mgr getInstance() {

        if (instance == null) {
            instance = new Demo6Mgr();
        }
        return instance;
    }

    /**
     * 回调处理
     *
     * @param parm
     */
    @Override
    public void proc(Event parm) {
        if (parm.id == ED.EVE1) {
            Long userid = (Long) parm.parm;
            Demo.print("Invoke event1,param:" + userid);
        }


    }

    /**
     * 注册事件
     */
    @Override
    protected void doReg() {
//        注册事件
        EventMgr.regist(ED.EVE1, this);
    }

    public void initData() {
        Demo.print("init Demo6");


    }


    public void demoLogic6(NetFramework net, ProtoMessage msg, long userid) {
        Demo.print("invoke Demologic6");
        EventMgr.addEvent(ED.EVE1, userid);
        JSONArray ret = new JSONArray();
        ret.add(userid);
        ret.add(msg.getData());
        net.write(ret);
    }

}
